#ifndef __BUOLA_GUI_DND_CX11DRAG_H__
#define __BUOLA_GUI_DND_CX11DRAG_H__

#include <buola/gui/x11/auto.h>
#include <buola/gui/x11/cx11dispatcher.h>

namespace buola { namespace gui { namespace x11 {

class CX11DndFilter;
    
class CX11DragWindowInfo
{
public:
    Window mWin;
    bool mChecked;
    bool mOK;
    CRect_d mRect;
};

class CX11Drag : public CX11EventFilter
{
protected:
    CX11Drag(CDrag*);
    virtual ~CX11Drag();

    bool OnX11Event(XEvent *pE);

    Window FindWindowIDAt(const CPoint_d &pP,int *pDndAware);

    //drag functions
    void DragStart();
    void DragMove(const CPoint_d&);
    void DragFinish();
    void DragDrop();
    void DragSendPosition(Window,const CPoint_d&);
    void DragSendEnter(Window);
    void DragSendLeave(Window);
    void DragSendFinished(Window);
    void DragSendDrop(Window);

    //callbacks
    void ProcessDndStatus(XClientMessageEvent*);

    //static callbacks
    static void PreProcessDndStatus(XClientMessageEvent*);

//////////
// data
//
//drag
    CDrag *mDrag;

    Window mDragLastOver;
    int mDragLastAware;
    bool mDragLastAccepted;
    bool mDragLastRejected;
    CPoint_d mDragLastPosition;
    CRect_d mDragLastRectangle;
    bool mDragWaitingStatus;
    bool mDragPositionChanged;
    bool mDragWaitingToDrop;

    CX11DragWindowInfo *mWindowCache;
    int mWindowCacheCount;

    static CDrag *mCurrentDrag;
    static CX11DndFilter *mX11DndFilter;

    friend class CX11Toolkit;
    friend class CToolkit;
    friend class CDrag;
    friend class CX11Dispatcher;
    friend class CX11DndFilter;
};

/*namespace x11*/ } /*namespace gui*/ } /*namespace buola*/ }

#endif
